<template>
	<view>
		<view class="list-item" v-for="(v, i) in list" :key="i">
			<image :src="v.image" mode=""></image>
			<view class="right">
				<view class="title">{{ v.title }}</view>
				<view class="desc">{{v.desc}}</view>
				<view class="price">¥：{{ v.price }}</view>
			</view>
		</view>
	</view>
</template>


<script>
	export default {
		data() {
			return {
				list: [],
				pageCode: 1,
				pageSize: 10
			}
		},
		methods: {
			async getList() {
				// 获取云数据库数据
				const resp = await uniCloud.database().collection('list').skip((this.pageCode - 1) * this.pageSize)
					.limit(this.pageSize).get();
				// 保存
				if (this.pageCode === 1) {
					this.list = resp.result.data
				} else {
					this.list = this.list.concat(resp.result.data)
				}
			}
		},
		onLoad() {
			this.getList()
		},
		onReachBottom() {
			this.pageCode++
			this.getList()
		}
	}
</script>


<style scoped lang="scss">
	.list-item {
		display: flex;

		image {
			width: 150px;
			height: 120px;
			flex-shrink: 0;
		}
	}
</style>